package com.xl6667.controller;

import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.dto.AddRoel;
import com.xl6667.domain.entity.Role;
import com.xl6667.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 获取所有角色
     * @param pageNum
     * @param pageSize
     * @param roleName
     * @param status
     * @return
     */

    @GetMapping("/list")
    public ResponseResult getRoleList(Integer pageNum,Integer pageSize,String roleName,String status){
        return roleService.getRoleList(pageNum,pageSize,roleName,status);
    }

    /**
     * 更改角色状态
     * @param role
     * @return
     */
    @PutMapping("/changeStatus")
    public ResponseResult changeStatusRole(@RequestBody Role role){
        return roleService.changeStatusRole(role);
    }
    /**
     *添加新角色
     */
    @PostMapping
    public ResponseResult addRole(@RequestBody AddRoel addRoel ){
        return roleService.addRole(addRoel);
    }

    /**
     * 获取角色信息
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public ResponseResult getRole(@PathVariable Long id){
        return roleService.getRole(id);
    }

    /**
     * 修改角色
     * @param addRoel
     * @return
     */
    @PutMapping()
    public  ResponseResult putRole(@RequestBody AddRoel addRoel){
        return roleService.putRole(addRoel);
    }
    /**
     * 删除角色
     */
    @DeleteMapping("{id}")
    public ResponseResult delRole(@PathVariable Long id){
        return roleService.delRole(id);
    }

    /**
     * 查询所有状态正常的角色
     */
    @GetMapping("/listAllRole")
    public ResponseResult getListAllRole(){
        return roleService.getListAllRole();
    }


}
